﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using SmartEP.DTO;
using System.Windows.Forms;
using SmartEP.Presenter;

namespace SmartDesktop
{
    public partial class PatientSearchDialog : Form, ISearchPatientView
    {
        private CheckInView _view;

        public PatientSearchDialog(CheckInView view)
        {
            InitializeComponent();
            _view = view;
        }

        #region Fields
        #endregion

        #region Property
        public string FirstName
        {
            get
            {
                return txtFirstName.Text;
            }
            set 
            { 

            }
        }

        public string LastName
        {
            get
            {
                return txtLastName.Text;
            }
            set
            {

            }
        }

        public DateTime DateOfBirth
        {
            get
            {
                return dtpBirthday.Value;
            }
            set
            {

            }
        }
        #endregion

        #region Events
        private void btnSearch_Click(object sender, EventArgs e)
        {

        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            txtFirstName.Clear();
            txtLastName.Clear();
        }

        private void lvPatients_DoubleClick(object sender, EventArgs e)
        {
            foreach (ListViewItem lvItem in lvPatients.SelectedItems)
            {
                Patient patient = new Patient();
                patient.LastName = lvItem.SubItems[0].Text;
                patient.Birthday = Convert.ToDateTime(lvItem.SubItems[1].Text);
                patient.AltPhone.Number = lvItem.SubItems[2].Text;
                this._view.SelectPatient = patient;
                this.Close();
            }
        }

        #endregion


    }
}
